package hotLeetcode;

class Item {
    String name;

    Item(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return name;
    }
}

class Egg extends Item {
    Egg() {
        super("鸡蛋");
    }
}

class Apple extends Item {
    Apple() {
        super("苹果");
    }
}

class Basket {
    Item item;

    Basket(Item item) {
        this.item = item;
    }

    void setItem(Item item) {
        this.item = item;
    }

    Item getItem() {
        return item;
    }

    void swapItemsWith(Basket otherBasket) {
        Item temp = this.item;
        this.item = otherBasket.item;
        otherBasket.item = temp;
    }

    @Override
    public String toString() {
        return "篮子里面有: " + item;
    }
}

public class BasketExchange {
    public static void main(String[] args) {
        Item egg = new Egg();
        Item apple = new Apple();

       Basket basketA = new Basket(egg);
        Basket basketB = new Basket(apple);


        // 交换篮子里的物品
        basketA.swapItemsWith(basketB);

    }
}